package com.yiqi.lottery.feature.mine.view;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.suozhang.framework.entity.bo.UserInfoBo;
import com.suozhang.framework.framework.AM;
import com.suozhang.framework.framework.BaseActivity;
import com.suozhang.framework.utils.T;
import com.yiqi.lottery.R;
import com.yiqi.lottery.entity.bo.TokenBo;
import com.yiqi.lottery.feature.mine.contract.MineContract;
import com.yiqi.lottery.feature.mine.dependencies.mine.DaggerMineComponent;
import com.yiqi.lottery.feature.mine.dependencies.mine.MinePresenterModule;

import javax.inject.Inject;

public class BasicInfoActivity extends BaseActivity implements MineContract.View {


    @BindView(R.id.toolbar)
    Toolbar mToolbar;

    @Inject
    MineContract.Presenter mPresenter;
    @BindView(R.id.iv_user_basic_info_head)
    ImageView mIvUserBasicInfoHead;
    @BindView(R.id.tv_user_basic_info_nick)
    TextView mTvUserBasicInfoNick;
    @BindView(R.id.tv_user_basic_info_name)
    TextView mTvUserBasicInfoName;
    @BindView(R.id.tv_user_basic_info_mobile)
    TextView mTvUserBasicInfoMobile;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_basic_info;
    }

    @Override
    protected void initView() {
        initToolBar(mToolbar, "基础资料", true, true);
    }

    @Override
    protected void initInjector() {
        DaggerMineComponent.builder().minePresenterModule(new MinePresenterModule(this)).build().inject(this);
    }

    @Override
    protected void initData() {
        if (AM.user().isLogin()){
            UserInfoBo userInfoBo=AM.user().getLoginResultCache();
            if (userInfoBo!=null){
                AM.image().bind(userInfoBo.getAvatar(), mIvUserBasicInfoHead);
                mTvUserBasicInfoNick.setText(TextUtils.isEmpty(userInfoBo.getNickname()) ? "暂无" : userInfoBo.getNickname());
                mTvUserBasicInfoName.setText(TextUtils.isEmpty(userInfoBo.getUsername()) ? "暂无" : userInfoBo.getUsername());
                mTvUserBasicInfoMobile.setText(TextUtils.isEmpty(userInfoBo.getMobile()) ? "暂无" : userInfoBo.getMobile().replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"));
            }
        }
    }

    @Override
    public void showUserInfoSuccess(UserInfoBo user) {



    }

    @Override
    public void showAuthSuccess(String msg) {

    }

    @Override
    public void showSendCodeSuccess(String code) {

    }

    @Override
    public void showEditPwdSuccess(String msg) {

    }

    @Override
    public void showSendCodeError(String error) {

    }

    @Override
    public void showError(String error) {
        T.showShort(error);
    }

    @Override
    public void showQiniuTokenSuccess(TokenBo data) {

    }

    @Override
    public void showUploadHashSuccess(String hash) {

    }


}
